import {
  mysqlTable,
  varchar,
  timestamp,
  datetime,
  bigint,
} from "drizzle-orm/mysql-core";
import { sql } from "drizzle-orm";

const id = bigint({ mode: "number", unsigned: true })
  .notNull()
  .autoincrement()
  .primaryKey();
const base = {
  updatedAt: timestamp("updated_at", { mode: "string" }).onUpdateNow(),
  createdAt: datetime("created_at", { mode: "string" })
    .default(sql`now()`)
    .notNull(),
  deletedAt: datetime("deleted_at", { mode: "string" }),
};

export const User = mysqlTable("users", {
  id,
  username: varchar({ length: 20 }).notNull().unique(),
  password: varchar({ length: 255 }).notNull(),
  nickname: varchar({ length: 20 }).notNull(),
  ...base,
});
